﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

namespace _1stVATCWed
{
    public partial class ChiTiettintuc : System.Web.UI.Page
    {
       private string IDtintuc;
        protected void Page_Load(object sender, EventArgs e)
        {
              
                IDtintuc = Request.QueryString["id"].ToString();
                load(IDtintuc);
            
        }
        private void load(string id)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
            SqlConnection conn = new SqlConnection(connectionString);          
            string sql = "select * from TINTUC where IDtintuc = @IDtintuc";
            SqlCommand cmd = new SqlCommand(sql, conn);

            cmd.Parameters.AddWithValue("@IDtintuc", id);
                
            conn.Open();
            SqlDataReader r = cmd.ExecuteReader();
            while (r.Read())
            {
                TextBox1.Text = (string)r["tieude"];
                Image1.ImageUrl=r["hinhanh"].ToString();
                TextBox2.Text = (string)r["chitiet"];
            }
            r.Close();
            conn.Close();
        }
    }
}